package in.muton.panels.paginator.helpers.links;

import in.muton.edushare.pages.batch.BatchSummary;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.edushare.common.vo.Batches;

public class BatchNameLink extends Link<Void> {
	private static final long serialVersionUID = 1151137446893668799L;
	public BatchNameLink(String id, final IModel<Batches> batchModel, String labelTag) {
		super(id);
		this.batchModel = batchModel;
		add(new Label(labelTag, new Model<String>(){
			private static final long serialVersionUID = 1L;
			@Override
			public String getObject(){
				if(batchModel.getObject().getBatchStatus() == Batches.BATCH_GRADUATED)
					return batchModel.getObject().getBatchName() + " (Graduated)";
				return batchModel.getObject().getBatchName();
			}
		}));
	}
	@Override
	public void onClick() {
		PageParameters params = new PageParameters();
		params.put("0", batchModel.getObject().getBatchId().toString());
		setResponsePage(BatchSummary.class, params);
	}
	private IModel<Batches> batchModel;
}
